home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9205 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.crystalball.com!news
  2. From: Larry Weiss <lfw@oc.com>
  3. Newsgroups: comp.lang.c
  4. Subject: named constants only?
  5. Date: Fri, 08 Mar 1996 10:11:26 -0600
  6. Organization: crystalball.com
  7. Message-ID: <31405C2E.6652@oc.com>
  8. References: <4g0elg$mdr@redstone.interpath.net> <4h0bbo$c0q@fohnix.metronet.com> <4h7ce0$ojd@news.interpath.net> <4h85sm$lm0@texas.nwlink.com> <danpop.825961872@rscernix> <313C5CD1.1209@oc.com> <4hmos4$ij2@news.interpath.net> <4hpd8a$d70@alterdial.UU.NET>
  9. NNTP-Posting-Host: external.oc.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. Tom Rogers wrote:
  16.  > 
  17.  > ...  Magic numbers are evil.  Don't use them not even
  18.  > once.  Your code will be reused, by you or someone else.  Even if
  19.  > you just use a magic number in one place it doesn't mean that in
  20.  > the future your routines won't get included in some other module
  21.  > with other new routines that need to use the 'same' magic number.
  22.  > 
  23.  > Furthermore, what does 5 or 7 or 10 mean?  It is NOT self documenting.
  24.  > Make it a well named constant and reduce the need for accompanying
  25.  > comments describing what the value is.
  26.  
  27.  
  28. I challenge you to look at all your source and see if there are any
  29. "naked" constants in it.    Most of the ones that you are likely to find
  30. will be easily justified as staying unobfuscated.   
  31.  
  32. The exercise will also most likely turn up some that are good candidates 
  33. for the #define naming mechanism.
  34.